// pages/publish/publish.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bottabData: app.globalData.bottabDataForSfc,
    userInfo: '',
    formlist: [        
      { isrequire: false, label: '人找车',type:"2", value: '', tips: '', img: 'orange1 icon-renzhaoche'},
      { isrequire: false, label: '车找人', type: "1",value: '', tips: '', img: 'orange1 icon-chezhaoren' },
      { isrequire: false, label: '货找车', type: "3", value: '', tips: '', img: 'orange1 icon-huozhaoche' },
      { isrequire: false, label: '车找货', type: "4",value: '', tips: '', img: 'orange1 icon-chezhaohuo' }
    ],
    keys: '',
    isBottom: true,
    transIndex: '',
    myIsRcruit: ''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      userInfo: JSON.parse(wx.getStorageSync('userInfo')),
      ['bottabData[1].current']: true
    })
    if(options.title){
      wx.setNavigationBarTitle({
        title: options.title,
      })
      if (options.index == 5) {
        var arr = [{ isrequire: false, label: '出租', type: "2", value: '', tips: '', img: 'orange1 icon-chuzu', value: '出租' },
          { isrequire: false, label: '出售', type: "1", value: '', tips: '', img: 'orange1 icon-chushou', value:'卖房'}]
      }
      this.setData({
        isBottom: false,
        transIndex: options.index,
        formlist: arr
      })
    }
    //wx.clearStorage();
  },
  showDetail:function(e){
    var item = e.currentTarget.dataset.item;
    var type = e.currentTarget.dataset.item.type;
    if (this.data.transIndex == 5){
      wx.navigateTo({
        url: '/pages/rentOut/rentOut?title='+item.value,
      })
    }
    else{
      if (type == '1' || type == '4') {
        if (this.data.userInfo.brandCar) {
          wx.navigateTo({
            url: "/pages/publishdetail/publishdetail?label=" + type
          })
        } else {
          wx.showModal({
            title: '提示',
            content: '你还没有完善车辆信息，请先去完善',
            success: function (res) {
              if (res.confirm) {
                wx.navigateTo({
                  url: "/pages/perfectInfo/perfectInfo"
                })
              } else {//取消
              }
            }
          })
        }
      } else {
        wx.navigateTo({
          url: "/pages/publishdetail/publishdetail?label=" + type
        })
      }
    }
    
    
    // url = "/pages/publishdetail/publishdetail?label={{item.type}}"
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})